﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Program.cs" company="Jim Liddell">
//   Copyright © Jim Liddell. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace TeamBuildBunnyConsole
{
    #region Usings

    using System;
    using System.ServiceModel;

    using TeamBuildBunny;
    using System.Globalization;
    using System.Collections;
    using System.Collections.Generic;

    #endregion

    public class Program
    {
        #region Public Methods

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">
        /// The parameter is not used.
        /// </param>
        public static void Main(string[] args)
        {
            using (ServiceHost buildCompletionServiceHost = new ServiceHost(typeof(BuildCompletionEndpoint)))
            using (ServiceHost checkInServiceHost = new ServiceHost(typeof(CheckInEndpoint)))
            {
                try
                {
                    // open the host to start listening for messages.
                    buildCompletionServiceHost.Open();
                    checkInServiceHost.Open();

                    // The service can now be accessed.
                    Console.WriteLine("The service is ready.");
                    Console.WriteLine("Press <ENTER> to terminate service.");
                    Console.ReadLine();

                    // close the hosts
                    checkInServiceHost.Close();
                    buildCompletionServiceHost.Close();
                }
                catch (TimeoutException timeProblem)
                {
                    Console.WriteLine(timeProblem.Message);
                    Console.ReadLine();
                }
                catch (CommunicationException commProblem)
                {
                    Console.WriteLine(commProblem.Message);
                    Console.ReadLine();
                }
            }
        }

        #endregion
    }
}